package com.ruoyi.special.service.impl;

import java.util.List;
import java.util.Map;

import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.db.domain.SpecialCostomInfo;
import com.ruoyi.db.mapper.SpecialCostomInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.db.mapper.SpecialCostomInfoProfitMapper;
import com.ruoyi.db.domain.SpecialCostomInfoProfit;
import com.ruoyi.special.service.ISpecialCostomInfoProfitService;
import com.ruoyi.common.core.text.Convert;

/**
 * 机构收益Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-03-12
 */
@Service
@DataSource(DataSourceType.SLAVE)
public class SpecialCostomInfoProfitServiceImpl implements ISpecialCostomInfoProfitService 
{
    @Autowired
    private SpecialCostomInfoProfitMapper specialCostomInfoProfitMapper;
    @Autowired
    private SpecialCostomInfoMapper specialCostomInfoMapper;

    /**
     * 查询机构收益
     * 
     * @param id 机构收益主键
     * @return 机构收益
     */
    @Override
    public SpecialCostomInfoProfit selectSpecialCostomInfoProfitById(Long id)
    {
        return specialCostomInfoProfitMapper.selectSpecialCostomInfoProfitById(id);
    }

    /**
     * 查询机构收益列表
     * 
     * @param specialCostomInfoProfit 机构收益
     * @return 机构收益
     */
    @Override
    public List<SpecialCostomInfoProfit> selectSpecialCostomInfoProfitList(SpecialCostomInfoProfit specialCostomInfoProfit)
    {
        return specialCostomInfoProfitMapper.selectSpecialCostomInfoProfitList(specialCostomInfoProfit);
    }

    /**
     * 查询机构收益列表
     *
     * @param specialCostomInfoProfit 机构收益
     * @return 机构收益
     */
    @Override
    public List<Map<String, Object>> selectSpecialCostomInfoProfitListMap(SpecialCostomInfoProfit specialCostomInfoProfit)
    {
        return specialCostomInfoProfitMapper.selectSpecialCostomInfoProfitListMap(specialCostomInfoProfit);
    }

    /**
     * 新增机构收益
     * 
     * @param specialCostomInfoProfit 机构收益
     * @return 结果
     */
    @Override
    public int insertSpecialCostomInfoProfit(SpecialCostomInfoProfit specialCostomInfoProfit)
    {

        SpecialCostomInfo costomInfo = specialCostomInfoMapper.selectSpecialCostomInfoById(specialCostomInfoProfit.getInfoId());

        specialCostomInfoProfit.setInfoName(costomInfo.getName());
        specialCostomInfoProfit.setCreateTime(DateUtils.getNowDate());
        return specialCostomInfoProfitMapper.insertSpecialCostomInfoProfit(specialCostomInfoProfit);
    }

    /**
     * 修改机构收益
     * 
     * @param specialCostomInfoProfit 机构收益
     * @return 结果
     */
    @Override
    public int updateSpecialCostomInfoProfit(SpecialCostomInfoProfit specialCostomInfoProfit)
    {
        specialCostomInfoProfit.setUpdateTime(DateUtils.getNowDate());
        return specialCostomInfoProfitMapper.updateSpecialCostomInfoProfit(specialCostomInfoProfit);
    }

    /**
     * 批量删除机构收益
     * 
     * @param ids 需要删除的机构收益主键
     * @return 结果
     */
    @Override
    public int deleteSpecialCostomInfoProfitByIds(String ids)
    {
        return specialCostomInfoProfitMapper.deleteSpecialCostomInfoProfitByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除机构收益信息
     * 
     * @param id 机构收益主键
     * @return 结果
     */
    @Override
    public int deleteSpecialCostomInfoProfitById(Long id)
    {
        return specialCostomInfoProfitMapper.deleteSpecialCostomInfoProfitById(id);
    }

    @Override
    public Map<String, Object> selectSpecialCostomInfoProfitTotalMap(SpecialCostomInfoProfit specialCostomInfoProfit) {
        return specialCostomInfoProfitMapper.selectSpecialCostomInfoProfitTotalMap(specialCostomInfoProfit);
    }
}
